package 单例模式;

public class DoubleCheckSingleton {
    private volatile static DoubleCheckSingleton uniqueInstance;
    private DoubleCheckSingleton(){

    }
    public static DoubleCheckSingleton getUniqueInstance(){
        if(uniqueInstance==null){
            //判断两次是否实例化，多线程可能出错；
            synchronized (DoubleCheckSingleton.class){
                if(uniqueInstance==null){
                    uniqueInstance=new DoubleCheckSingleton();
                }
            }
        }
        return uniqueInstance;
    }
}
